package com.fjwt.gz.mch.ctrl.lite.feedback;

import com.alibaba.fastjson2.JSONObject;
import com.fjwt.gz.core.model.ApiRes;
import com.fjwt.gz.db.dto.LiteFeedbackDTO;
import com.fjwt.gz.mch.ctrl.CommonCtrl;
import com.fjwt.gz.service.impl.LiteFeedbackService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Objects;

/**
 * 用户反馈接口
 */
@Slf4j
@RestController
@RequestMapping("/api/liteFeedback")
public class LiteFeedbackController extends CommonCtrl {

    @Autowired
    private LiteFeedbackService liteFeedbackService;

    /**
     * 添加反馈
     */
    @PostMapping("/add")
    public ApiRes addFeedback() {
        String appId = getCurrentUser().getAppId();
        Long fansId = getCurrentUser().getFansId();
        LiteFeedbackDTO feedback = getObject(LiteFeedbackDTO.class);
        feedback.setAppId(appId);
        feedback.setFansId(fansId);
        log.info("C端用户反馈信息，请求地址：/api/liteFeedback/add，请求参数：{}", JSONObject.toJSONString(feedback));
        liteFeedbackService.addFeedback(feedback);
        return ApiRes.ok();
    }
}
